/// Author: QP
/// Version: 1.0
/// Date:2021/08
/// HCC服务调用历史记录
Class HCC.SVR.ServiceLog Extends (%Persistent, %XML.Adaptor)
{

Parameter DSTIME As STRING [ Constraint = ",AUTO,MANUAL", Flags = ENUM ] = "AUTO";

Parameter DSINTERVAL = 1;

/// 服务类型。对应46个互联互通服务
Property ServiceType As %String;

/// 服务会话ID
Property Session As %String;

/// 会话开始时间
Property BeginTS As %TimeStamp;

/// 会话结束时间
/// 由后台任务同步
Property EndTS As %TimeStamp;

/// 会话结果
/// 由后台任务同步
Property Result As Ens.DataType.MessageStatus;

/// 按秒毫计算的服务完成时间
Property Duration As %Integer [ Calculated, SqlComputeCode = {set {Duration}=##class(HCC.SVR.ServiceLog).GetDuration({BeginTS},{EndTS})}, SqlComputed, SqlComputeOnChange = EndTS ];

Method DurationGet() As %Integer
{
    Quit ..GetDuration(..BeginTS,..EndTS)
}

ClassMethod GetDuration(pBeginTS, pEndTS = "") As %Integer
{
    Return:( pEndTS ="") 0
    Return $SYSTEM.SQL.Functions.DATEDIFF("ms",pBeginTS,pEndTS)
}

Index IndSvrType On ServiceType [ Type = bitmap ];

Index IndResult On Result [ Type = bitmap ];


}
